import { Component, OnInit } from '@angular/core';
import { FetchService } from "../../../../core/net/fetch.service";

@Component({
  selector: 'app-mng-industrial',
  templateUrl: './mng-industrial.component.html',
  styleUrls: ['../mng-water-report.component.scss']
})
export class MngIndustrialComponent implements OnInit {
  radioValue = '0';

  today: Date;
  datePicker: Date = new Date();

  tableData = [];
  basicOpts: any = {
    title: {
      text: "",
      x: "center",
      textStyle: {
        color: "#777",
        fontSize: 16
      }
    },
    color: ['#3398DB', '#dd7408'],
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    tooltip: {
      trigger: "axis"
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['4h', '8h', '12h', '16h', '20h', '24h']
    },
    yAxis: {
      type: "value"
    },
    series: [
      {
        name: '1',
        type: 'line',
        stack: '总量',
        data: []
      },
      {
        name: '2',
        type: 'line',
        stack: '总量',
        data: []
      }
    ]
  };
  customOpts: any = {};
  modalTitle: string = '干渠进口水位流量历史数据';
  modalShow: boolean = false;
  nzBodyStyle: any = {
    padding: '16px 20px 0'
  };

  constructor(private fetchService: FetchService) {
  }

  ngOnInit() {
    this.today = new Date();
  }

  selectedAreaChanged(): void {
    console.log(this.radioValue);
  }

  openDetailModal(): void {
    this.modalShow = true;
  }

  export(): void {
      const param = {};
      this.fetchService.export('muw/wrsMuwIndData/export', param).subscribe((res: any) => {
          const blob = new Blob([res], {type: 'application/vnd.ms-excel    application/x-excel;charset=utf-8'});
          const elink = document.createElement('a');

          elink.download = `工业取水.xlsx`;
          elink.href = URL.createObjectURL(blob);
          document.body.appendChild(elink);
          elink.click();
          URL.revokeObjectURL(elink.href); // 释放URL 对象
          document.body.removeChild(elink);
      });
  }

  print(): void {}

  onCancel() {
    this.modalShow = false;
  }

  queryInfo(date): void {
    console.log(date);
  }
}
